﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using HotelManagement.DAO;
using HotelManagement.DTO;

namespace HotelManagement.BLO
{
    class AccountBLO
    {
        
        //private AccountDTO account;
        private AccountDAO dao;
        private string _error;

        public string Error
        {
            get { return _error; }
            set { _error = value; }
        }

        public AccountBLO()
        {
            //account = new AccountDTO();
            dao = new AccountDAO();
        }

        //public AccountBLO(AccountBLO blo)
        //{
        //    this.account = new AccountDTO(blo.account);
        //    dao = new AccountDAO();
        //}

        public bool Insert(AccountDTO account)
        {
            return dao.Insert(account);
        }
        public bool Update(AccountDTO account)
        {
            return dao.Update(account);
        }
        public bool Delete(AccountDTO account)
        {
            return dao.Delete(account);
        }
        public DataTable Select()
        {
            return dao.Select();
        }
        public bool Login(string pUser, string pPass)
        {
            AccountDTO info = dao.GetInformationOfAUser(pUser);
            if (info==null || pPass != info.Password)
            {
                return false;
            }
            return true;
        }

        public AccountDTO GetInformationOfAUser(string pUserName)
        {
            //AccountDTO acc = new AccountDTO();
            if (pUserName=="")
            {
                return null;
            }
            AccountDTO info = dao.GetInformationOfAUser(pUserName);
            if (info.UserName=="")
            {
                return null;
            }
            return info;
        }
    }
}
